package com.iris.live.services.data.repositories;

import com.iris.live.services.data.models.Lsh保险设置Model;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by sxy on 2016/7/13.
 */
public interface Lsh保险设置Repository extends JpaRepository<Lsh保险设置Model, Integer>, JpaSpecificationExecutor<Lsh保险设置Model> {

    @Modifying
    @Query("delete from Lsh保险设置Model s where s.许可 = ?1 and s.保险公司编号 = ?2 and s.车型编号 = ?3")
    int delBy许可And保险公司编号And车型编号(String license, int companyId, int carTypeId);

    @Modifying
    @Query("delete from Lsh保险设置Model s where s.许可 = ?1 and s.车型编号 = ?2")
    int delBy许可And车型编号(String license, int carTypeId);

    /**
     * 根据许可和车型编号,查找保险设置
     * @param permit 许可
     * @param carId 车型编号
     * @return 返回
     */
    @Query("select s from Lsh保险设置Model s where s.许可 = ?1 and s.车型编号 = ?2")
    List<Lsh保险设置Model> findByPermitAndCarId(String permit, Integer carId);

}
